import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;

/**
 * 
 * this class is ManUI gui
 *
 */
public class ManUI extends JPanel{
	/**
	 * label for user id
	 */
	private JLabel lblUserID = null;
	/**
	 * title for the current window  
	 */
	private JLabel lbltitle = null;
	/**
	 * block button 
	 */
	private JButton btnBlock = null;
	/**
	 * unblock button 
	 */
	private JButton btnUnBlock = null;
	/**
	 * back button 
	 */
	public JButton btnBack = null;
	/**
	 * TextField for id
	 */
	private JTextField IdText = null;
	private String id;
	/**
	 * help button 
	 */
	public JButton btnHelp = null;

	public ManUI() {
		super();
		initialize();
	}

	private void initialize() {
		
		btnBlock = new JButton(); // block button
		btnBlock.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				SQL s = new SQL (id , 7) ;
				s.accept();
			}
		});
		btnBlock.setBounds(new Rectangle(120, 180, 90, 25));
		btnBlock.setText("Block");
		this.add(btnBlock,null);
		
		btnUnBlock = new JButton(); // unblock button
		btnUnBlock.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				SQL s = new SQL (id ,8) ;
				s.accept();

				
			}
		});
		btnUnBlock.setBounds(new Rectangle(273, 180, 90, 25));
		btnUnBlock.setText("UnBlock");
		this.add(btnUnBlock,null);
		
		btnBack = new JButton("Back");
		btnBack.setBounds(200, 300, 86, 25);
		this.add(btnBack,null);
		this.setVisible(true);
	
		
		IdText = new JTextField(); // id text field
		IdText.setBounds(new Rectangle(222, 90, 128, 25));
		IdText.setText("Id");
		this.add(IdText,null);
		IdText.addFocusListener(new java.awt.event.FocusAdapter() 
		{
			public void focusLost(java.awt.event.FocusEvent e) 
			{
				System.out.println("focusLost()"); 
				id=IdText.getText();			
			}
		}
		);
		
		lblUserID = new JLabel("Parent ID:");
		lblUserID.setBounds(132, 90, 110, 25);
		this.add(lblUserID);
		

		lbltitle = new JLabel("Block Parent");
		lbltitle.setBounds(168, 31, 110, 14);
		this.add(lbltitle);
		
		this.setSize(400, 321);
		this.setLayout(null);
		this.setVisible(true);
		
		btnHelp = new JButton("Help");
		btnHelp.setBounds(390, 11, 80, 19);
		btnHelp.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				  HelpWin help = new HelpWin ("Enter Parent id and then click on"," 'Block' or 'UnBlock' button");
				  System.out.println("user press Help button");
			}
		});
		this.add(btnHelp,null);
	}

}
